# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.


def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.

def calculate(a, b):
    """
    计算两个数的基本运算
    """
    # 加法
    addition = a + b
    # 减法
    subtraction = a - b
    # 乘法
    multiplication = a * b
    # 除法（处理除零错误）
    try:
        division = a / b
    except ZeroDivisionError:
        division = "错误：除数不能为零"
    
    # 返回所有计算结果
    return {
        '加法': addition,
        '减法': subtraction,
        '乘法': multiplication,
        '除法': division
    }

# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    print_hi('PyCharm')
    
    # 演示 calculate 函数
    print("\n=== 计算器演示 ===")
    result = calculate(10, 3)
    for operation, value in result.items():
        print(f"{operation}: {value}")
    
    # 演示除零错误处理
    print("\n=== 除零错误处理 ===")
    result_zero = calculate(10, 0)
    for operation, value in result_zero.items():
        print(f"{operation}: {value}")

# See PyCharm help at https://www.jetbrains.com/help/pycharm/
